package com.gla.service;

import com.gla.dao.VideoMapper;
import com.gla.domain.Commodity;
import com.gla.domain.Shop;
import com.gla.domain.Video;
import com.gla.result.Result;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class VideoService {

    @Resource
    VideoMapper videoMapper;

    public List<Video> getAllShop(){
        List<Video> videoList = videoMapper.getAllShop();
        for(Video video:videoList){
            String name= findCommodityName(video.getCommodity_id());
            video.setCommodity_name(name);
        }
        return videoList;

    }

    public List<Commodity> getPet(){
        List<Commodity> petList = videoMapper.getPet();
        return petList;
    }

    public List<Commodity> getPetGoods(){
        List<Commodity> petGoodsList = videoMapper.getPetGoods();
        return petGoodsList;
    }

    private String findCommodityName(Integer id){
        Commodity commodity = videoMapper.findCommodityName(id);
        String name = commodity.getName();
        return name;
    }
}
